home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- **
- ** Project Name: DropInfo
- ** File Name: DIUtils.c
- **
- ** Description: Generic utility routines used by DropInfo
- **
- *******************************************************************************
- ** A U T H O R I D E N T I T Y
- *******************************************************************************
- **
- ** Initials Name
- ** -------- -----------------------------------------------
- ** SCS Stephan Somogyi
- **
- *******************************************************************************
- ** R E V I S I O N H I S T O R Y
- *******************************************************************************
- **
- ** Date Time Author Description
- ** -------- ----- ------ ---------------------------------------------
- ** 29.22.91 SCS Original Version scavenged from MyMacStuff parts
- **
- ******************************************************************************/
-
- #ifndef THINK_C
- #define TRUE true
- #define FALSE false
-
- #include <Dialogs.h>
- #include <Controls.h>
- #include <OSUtils.h>
- #endif
-
- #include "DIUtils.h"
-
-
- /* Flashes an item, in DropInfo's case a button, briefly. Used to show the
- effect of a kbd-shortcut.
- */
- void
- FlashItem(DialogPtr pDial, short pItem)
- {
- short lType;
- ControlHandle lHndl;
- Rect lBox;
- long lDummy;
-
- GetDItem(pDial, pItem, &lType, (Handle *) &lHndl, &lBox);
- if ((**lHndl).contrlHilite == 255)
- return;
- else {
- HiliteControl(lHndl, 1);
- Delay(8, &lDummy);
- HiliteControl(lHndl, 0);
- }
- }
-
-
- /* Disables or enables a item in a dialog box depending on the state of the
- parameter "on".
- */
- void
- DisEnAble(DialogPtr dptr, short item, Boolean on)
- {
- Rect aRect;
- short iType;
- Handle iHndl;
-
- GetDItem(dptr, item, &iType, &iHndl, &aRect);
- if (on == TRUE)
- HiliteControl((ControlHandle) iHndl, 0);
- else
- HiliteControl((ControlHandle) iHndl, 255);
-
- }
-
-
- /* Checks or unchecks either a checkbox or a radio button depending on the
- state of the parameter "on".
- */
- void
- CheckBox(DialogPtr dptr, short item, Boolean on)
- {
- Rect aRect;
- short iType;
- Handle iHndl;
-
- GetDItem(dptr, item, &iType, &iHndl, &aRect);
- if (on == TRUE)
- SetCtlValue((ControlHandle) iHndl, 1);
- else
- SetCtlValue((ControlHandle) iHndl, 0);
-
- } /* CheckBox */
-
-
- /* Gets the contents of the dialog text item specified */
- void
- GetTxtItem(DialogPtr dptr, short item, Str255 *txt)
- {
- Rect aRect;
- short iType;
- Handle iHndl;
-
- GetDItem(dptr, item, &iType, &iHndl, &aRect);
- #ifndef THINK_C
- GetIText(iHndl, (Str255) txt);
- #else
- GetIText(iHndl, txt);
- #endif
-
- } // GetTxtItem//
-
-
- /* Sets the contents of the dialog text item specified */
- void
- SetTxtItem(DialogPtr dptr, short item, Str255 *txt)
- {
- Rect aRect;
- short iType;
- Handle iHndl;
-
- GetDItem(dptr, item, &iType, &iHndl, &aRect);
- #ifndef THINK_C
- SetIText(iHndl, (Str255) txt);
- #else
- SetIText(iHndl, txt);
- #endif
-
- } /* SetTxtItem */
-
-
- /* Creates the standard outline around a dialog's default item */
- void
- DefBut(DialogPtr dptr)
- {
- Rect aRect;
- short iType;
- Handle iHandle;
- PenState oldPen;
- GrafPtr Sherry; /* old port */
-
-
- GetPenState(&oldPen);
- GetPort(&Sherry);
- SetPort(dptr);
- GetDItem(dptr, ((DialogPeek) dptr)->aDefItem, &iType, &iHandle, &aRect);
- InsetRect(&aRect, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(&aRect, 16, 16);
- SetPort(Sherry);
- SetPenState(&oldPen);
-
- } /* DefBut */
-